<?php
session_cache_expire(999999999);
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
if(!isset($_SESSION['db'])){
	$addressbrowser = $_SERVER['SERVER_NAME'];
	$temp = explode(".", $addressbrowser);
	$connection = mysql_connect("1.234.53.52", "cam", "5678" ) ;
	//$connection = mysql_connect("localhost", "root", "root" ) ;
	mysql_select_db("elihan", $connection);
	mysql_query("set names 'utf8'");
	$selectdatabase = mysql_query("SELECT am.DatabaseName,am.Logo from ac_eli_manager am where am.KeyName='$temp[0]' and am.`Status` = 2");
	$result = mysql_fetch_assoc($selectdatabase);

	$_SESSION['Logo']=$result['Logo'];
		
	$_SESSION['db']= $result['DatabaseName'];
	mysql_close($connection);
}
$database = $_SESSION['db'];
	try {
		ini_set('display_errors', 0);
		$connection_ajax = mysql_connect("1.234.53.52", "cam", "5678" ) ;
		//$connection_ajax = mysql_connect("localhost", "root", "root" ) ;
		if(!$connection_ajax){		
			session_destroy();	
			include 'backlogin.php';	
		}		
		if(!mysql_select_db("$database")){		
			session_destroy();	
			include 'backlogin.php';	
		}
		if(!mysql_query("SET CHARACTER SET 'utf8'", $connection_ajax)){		
			session_destroy();	
			include 'backlogin.php';	
		}
	} catch (Exception $e) {
		session_destroy();
		include 'backlogin.php';	
		
	}
		
?>